package com.xuantu.pattern.create.singleton;

/**
 * 懒汉模式
 * 线程不安全
 * @author fengzp
 *
 */
public class LazySingleton extends BaseSingleton {

	private static volatile LazySingleton instance;
	
	private LazySingleton() {}
	
	public /*synchronized*/ static LazySingleton getInstance() {
		if (null == instance) {
			//synchronized(LazySingleton.class) {  //线程不安全
				instance = new LazySingleton();
			//}
		}
		
		return instance;
	}
	 
}
